package jnpf.engine;

import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.engine.entity.*;
import jnpf.engine.fallback.FlowTaskApiFallback;
import jnpf.engine.model.flowengine.FlowModel;
import jnpf.engine.model.flowengine.FlowPagination;
import jnpf.engine.model.flowtask.PaginationFlowTask;
import jnpf.engine.model.flowtemplate.FlowTemplateCrForm;
import jnpf.engine.model.flowtemplate.FlowTemplateInfoVO;
import jnpf.exception.WorkFlowException;
import jnpf.model.FlowWorkListVO;
import jnpf.permission.model.user.WorkHandoverModel;
import jnpf.utils.FeignName;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * api接口
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * @date 2021/3/15 11:55
 */
@FeignClient(name = FeignName.WORKFLOW_SERVER_NAME, fallback = FlowTaskApiFallback.class, path = "/Engine/flowTemplateJson")
public interface FlowTaskApi {

    //———————————————流程任务数据——————————

    /**
     * 列表（待我审批）
     *
     * @return
     */
    @PostMapping("/GetWaitList")
    PageListVO getWaitList(@RequestBody PaginationFlowTask pagination);

    /**
     * 列表（我已审批）
     *
     * @return
     */
    @PostMapping("/GetTrialList")
    PageListVO getTrialList(@RequestBody PaginationFlowTask pagination);

    /**
     * 列表（订单状态）
     *
     * @return
     */
    @PostMapping("/GetOrderStaList")
    List<FlowTaskEntity> getOrderStaList(@RequestBody List<String> idAll);

    @PostMapping("/GetTaskList")
    List<FlowTaskEntity> getTaskList(@RequestBody String[] ids);

    /**
     * 列表
     *
     * @return
     */
    @GetMapping("/getDelegateList")
    List<FlowDelegateEntity> getDelegateList();

    /**
     * 列表
     *
     * @return
     */
    @PostMapping("/getCirculateList")
    PageListVO getCirculateList(@RequestBody PaginationFlowTask pagination);
    //———————————————流程引擎数据——————————

    @PostMapping(value = "/getListAll")
    PageListVO getListAll(@RequestBody FlowPagination pagination);


    @PostMapping("/getTemplateList")
    List<FlowTemplateEntity> getTemplateList(@RequestBody List<String> templaIdList);


    @GetMapping("/getFlowTemplateJsonEntity")
    FlowTemplateJsonEntity getFlowTemplateJsonEntity(@RequestParam("id") String id) throws WorkFlowException;

    @GetMapping("/getInfoSubmit")
    ActionResult<FlowTaskEntity> getInfoSubmit(@RequestParam("id") String id);

    @PostMapping("/deleteFlowTask")
    ActionResult deleteFlowTask(@RequestBody FlowTaskEntity taskEntity);

    @PostMapping("/createTemplate")
    ActionResult createTemplate(@RequestBody FlowTemplateCrForm templateCrForm);

    @PostMapping("/updateTemplate/{id}")
    ActionResult updateTemplate(@PathVariable("id") String id, @RequestBody FlowTemplateCrForm templateCrForm);

    @GetMapping("/getTemplateInfo/{id}")
    FlowTemplateInfoVO getTemplateInfo(@PathVariable("id") String id);

    @GetMapping("/deleteTemplateInfo/{id}")
    ActionResult deleteTemplateInfo(@PathVariable("id") String id);

    @GetMapping("/saveLogicFlowAndForm" )
    void saveLogicFlowAndForm(@RequestParam("id" ) String id);

    /**
     * 获取待办及负责流程
     */
    @GetMapping("/flowWork" )
    FlowWorkListVO flowWork(@RequestParam("fromId") String fromId);

    /**
     * 获取待办及负责流程
     */
    @PostMapping("/saveFlowWork" )
    boolean saveFlowWork(@RequestBody WorkHandoverModel workHandoverModel);

    /**
     * 批量保存流程
     * @param flowModel
     * @throws WorkFlowException
     */
    @PostMapping("/batchCreateOrUpdate")
    ActionResult batchCreateOrUpdate(@RequestBody FlowModel flowModel) ;

    @PostMapping("/pushmessage" )
    ActionResult List2(@RequestBody PaginationFlowTask paginationFlowTask) ;

}
